import { request } from "@/utils/service"
import type * as Table from "./types/table"
import { getToken } from "@/utils/cache/cookies"
import axios from "axios"
const baseURL = import.meta.env.VITE_BASE_API
// console.log(baseURL)
/** 增 */
export function createTableDataApi(data: Table.ICreateTableRequestData) {
  return request({
    url: "staff/add",
    method: "post",
    data
  })
}

/** 删 */
export function deleteTableDataApi(id: string) {
  return request({
    url: "staff/del",
    method: "delete",
    params: {
      id
    }
  })
}

/** 改 */
export function updateTableDataApi(data: Table.IUpdateTableRequestData) {
  return request({
    url: "staff/update",
    method: "put",
    data
  })
}

/** 查 */
export function getTableDataApi(params: Table.IGetTableRequestData) {
  return request<Table.GetTableResponseData>({
    url: "staff/query",
    method: "get",
    params
  })
}

/**图片上传 */
export function uploadImageLIst(data: any) {
  return request({
    url: "staff/upload",
    method: "post",
    headers: {
      "Content-Type": "multipart/form-data",
      token: getToken()
    },
    data
  })
}
/** 团队增 */
export function addDepartment(data: Table.ICreateTableRequestData) {
  return request({
    url: "department/add",
    method: "post",
    data
  })
}
/**下载 */
export function downLoadTable(data: any) {
  return axios({
    url: `${baseURL}/staff/downStaff`,
    method: "post",
    headers: {
      "Content-Type": "multipart/form-data",
      token: getToken()
    },
    data,
    responseType: "blob"
  })
}
